package com.itlong.cloud.enumerate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <desc>
 * 云电梯呼梯记录来源枚举类
 * </desc>
 *
 * @createDate 2017/9/13
 */
public enum CallElevatorRecordSourceEnum {

    JIAR("家半径", 1),//APP
    APPLETS("小程序", 2),
    WELINK("Welink", 3),
    DEVICE_SYNC("设备同步", 4),
    CLOUD("云端SDK", 5),
    ROBOT("机器人SDK", 6);


    private String description;
    private Integer type;


    CallElevatorRecordSourceEnum(String value, Integer type) {
        this.type = type;
        this.description = value;
    }

    /**
     * {@link #description}的getter。
     */
    public String getDescription() {
        return description;
    }

    /**
     * {@link #type}的getter。
     */
    public Integer getType() {
        return type;
    }


    /**
     * <p>
     * 获取枚举的描述。
     * <p/>
     *
     * @param type 类型值。
     * @return {@link String}。
     */
    public static String getDescription(int type) {
        CallElevatorRecordSourceEnum[] types = CallElevatorRecordSourceEnum.values();
        for (CallElevatorRecordSourceEnum limitCategory : types) {
            if (limitCategory.getType() == type) {
                return limitCategory.getDescription();
            }
        }
        return null;
    }


    /**
     * <p>
     * 获取枚举的类型。
     * <p/>
     *
     * @param type 类型值。
     * @return {@link int}。
     */
    public static int getType(Integer type) {
        CallElevatorRecordSourceEnum[] types = CallElevatorRecordSourceEnum.values();
        for (CallElevatorRecordSourceEnum limitCategory : types) {
            if (limitCategory.getType() == type) {
                return limitCategory.getType();
            }
        }
        return 0;
    }


    /**
     * <p>
     * 获取枚举的list。
     * <p/>
     *
     * @return {@link java.util.List}。
     */
    public static List<Map> toList() {
        List<Map> mapList = new ArrayList<Map>();
        CallElevatorRecordSourceEnum[] ds = CallElevatorRecordSourceEnum.values();
        for (CallElevatorRecordSourceEnum one : ds) {
            Map<String, Object> term = new HashMap<String, Object>();
            term.put("type", one.getType());
            term.put("description", one.getDescription());
            mapList.add(term);
        }
        return mapList;
    }
}
